home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / mj90.lha / ProPage / CpuIdIII-35.ppd (.txt) < prev    next >
Encoding:
Professional Page Document  |  1991-06-12  |  28.2 KB  |  301 lines

  1. Professional Page V1.2
  2. dPENV
  3. Helvetica
  4. Bookman
  5. Courier
  6. zapfdingbats
  7. helvetican
  8. Green
  9. >Blue
  10. ~Yellow
  11. Magenta
  12. PcpuIII35.ppg
  13. ^Adam Levin
  14. Disabling Sprite DMA from a Vertical Blank Interrupt
  15. K1PTXT
  16. Z\n\B\ff<Courier>\fs<7>\jf\lr<105>\ls<0.000>\ps<100>\t<0>\c<Black>U259 U260 U261 U262\.
  17. hfPBOX
  18. lFPBOX
  19. W\n\ff<helvetican>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Socketed Chip RAM\.
  20. X\n\ff<helvetican>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Soldered Chip\MRAM\.
  21. _PTXT
  22. Z\n\B\ff<Courier>\fs<7>\jf\lr<105>\ls<0.000>\ps<100>\t<0>\c<Black>U263 U264 U265 U266\.
  23. Z\n\B\ff<Courier>\fs<7>\jf\lr<105>\ls<0.000>\ps<100>\t<0>\c<Black>U271 U272 U273 U274\.
  24. RPTXT
  25. y\n\B\ff<Courier>\fs<7>\jf\lr<105>\ls<0.000>\ps<100>\t<0>\c<Black>                               U267 U268 U269 U270\.
  26. Black
  27. Black
  28.     iPTXT
  29. K\n\B\ff<Helvetica>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Exec\.
  30. W\n\B\ff<Helvetica>\fs<10>\jc\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Page III - 36\.
  31. e\n\B\ff<Helvetica>\fs<10>\jr\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Identifying the Amiga's CPU\.
  32. b5PBOX
  33. `\n\B\I\O\ff<Helvetica>\fs<30>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Amiga Mail\ff<Times>
  34. Black
  35. Black
  36. Black
  37. Black
  38. nPBOX
  39. b\n\B\ff<Helvetica>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Identifying the Amiga's CPU\.
  40. W\n\B\ff<Helvetica>\fs<10>\jc\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Page III - 37\.
  41. +PBOX
  42. N\n\B\ff<Helvetica>\fs<10>\jr\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Exec\.
  43. zPTXT
  44. V\n\B\I\O\ff<Helvetica>\fs<30>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Amiga Mail
  45. UPBOX
  46. ~PSGR
  47. Black
  48. Black
  49. GPBOX
  50. nPTXT
  51. %b\n\B\ff<Times>\fs<30>\lr<115>\ls<0.000>\ps<100>\t<0>\c<Black>
  52. Identifying the Amiga's CPU\fs<14>
  53. by Dave Haynie
  54. \b\fs<12>Amiga's come in a variety of configurations including models that use the Motorola 68000, the 68020 and now the 68030.  While it's not that  difficult to figure out which CPU you're using by trying certain instructions  and trapping the exception if they break, this isn't necessary.  In fact, the  Amiga OS sets an ExecBase flag on system startup that can identify which  processor (and coprocessor) is installed.  The CPU type flags are stored  in ExecBase->AttnFlags.  
  55. Under V1.3 and earlier versions of the OS, the system can't tell the  difference between a 68020 and a 68030, or a 68881 and a 68882.  That's no big surprise, since both the 68030 and 68882 were introduced well after the last version of the OS was released.  Under the new V2.0 version of the  operating system, support for identifying these processors has been added.  If you are running under V2.0 of the operating system, you can just look at ExecBase->AttnFlags to find out what processor is installed.  The AttnFlags field will be set as follows:
  56. \ff<Courier>\fs<8>/****** V2.0 Bit defines for AttnFlags ************************/
  57. /*  Processors and Co-processors: */
  58. #define AFB_68010\s0\s/*  also set for 68020  */
  59. #define AFB_68020\s1\s/*  also set for 68030  */
  60. #define AFB_68030\s2\s/* New flag under V2.0  */
  61. #define AFB_68040\s3\s/* New flag under V2.0  */
  62. #define AFB_68881\s4\s/*  also set for 68882  */
  63. #define AFB_68882\s5\s/* New flag under V2.0  */
  64. #define AFF_68010\s(1L<<0)
  65. #define AFF_68020\s(1L<<1)
  66. #define AFF_68030\s(1L<<2)\s/* New flag under V2.0  */
  67. #define AFF_68040\s(1L<<3)\s/* New flag under V2.0  */
  68. #define AFF_68881\s(1L<<4)
  69. #define AFF_68882\s(1L<<5)\s/* New flag under V2.0  */\ff<Times>
  70. \fs<12>
  71. However, if you are running under V1.3 or earlier versions of the operating  system, this method will not work with the 68030 and 68882 processors.  To  overcome this problem you can use the code shown below to identify which  CPU the system is using under V1.3.  There are three functions to link with  your code to identify the processor and coprocessor: GetCPUType(), GetFPUType(), and GetMMUType().
  72. \B\ff<Courier>\fs<9>ULONG GetCPUType(void)\b
  73. \s\ff<Times>\fs<12>Returns a number, representing the type of CPU in the system: 68000L, 68010L, 
  74. \s68020L, or 68030L.\ff<Courier>\fs<9>
  75. \BULONG GetFPUType(void)\b
  76. \s\ff<Times>\fs<12>Returns a number, representing the type of FPU in the system: 0L (no FPU), 68881L, 
  77. \sor 68882L.\ff<Courier>\fs<9>
  78. \BULONG GetMMUType(void)\b
  79. \s\ff<Times>\fs<12>Returns a number, representing the type of MMU in the system: 0L (no MMU),  \s68851L, 68030L, or 0xFFFFFFFFL (this means an FPU responding to a MMU 
  80. \saddress).
  81. In order to find out which processor is present, GetCPUType() first checks  ExecBase->AttnFlags.  Under V1.3 if this is set to AFF_68020, then the  processor may be either a 68020 or a 68030.  GetCPUType() then checks to  see if the processor is really a 68030 by trying to invert the instruction  burst enable bit, which doesn't exist on the 68020.  If that bit can be  changed, then it is a 68030 system.   
  82. Similar methods are used in GetMMUType() and GetFPUType().  These functions  first look at ExecBase->AttnFlags and then do extra tests based on unique features of a given coprocessor to find out what is present in the system.  The functions are listed below.\ff<Courier>\fs<7>
  83. \fs<6>\lr<105>;======================================================================
  84. ;\sFrom SetCPU V1.5
  85. ;\sby Dave Haynie
  86. ;\s68030 Assembly Function Module
  87. ;\sThis module contains functions that access features of the 68020,
  88. ;\s68030, and 68851 chips, and ID all of these, plus the 68881/68882
  89. ;\sFPU chips, reset stuff, and exception handler.
  90. ;======================================================================
  91. ;\sMacros & constants used herein...
  92. ;======================================================================
  93. CALLSYS macro   *
  94. \sjsr     LVO\\1(A6)
  95. \sendm
  96. CIB_ENABLE\sEQU\s0
  97. CIB_FREEZE\sEQU\s1
  98. CIB_ENTRY\sEQU\s2
  99. CIB_CLEAR\sEQU\s3
  100. CIB_BURST\sEQU\s4
  101. CDB_ENABLE\sEQU\s8
  102. CDB_FREEZE\sEQU\s9
  103. CDB_ENTRY\sEQU\s10
  104. CDB_CLEAR\sEQU\s11
  105. CDB_BURST\sEQU\s12
  106. CDB_WALLOC\sEQU\s13
  107. AFB_68030\sEQU\s2
  108. ATNFLGS\s\sEQU\s$129
  109. LVOSupervisor\sEQU\s-30
  110. LVOSuperState\sEQU\s-150
  111. LVOFindTask\sEQU\s-294
  112. LVOAllocTrap\sEQU\s-342
  113. LVOFreeTrap\sEQU\s-348
  114. ;======================================================================
  115. ;\sNeed just a little more stuff
  116. ;======================================================================
  117. \sNOLIST
  118. \sinclude "exec/execbase.i"
  119. \sinclude "exec/tasks.i"
  120. \sLIST
  121. *\smachine mc68020
  122. *\s\smc68881
  123. ;**********************************************************************
  124. ;\sThis section contains functions that identify and operate on CPU 
  125. ;\sthings.
  126. ;**********************************************************************
  127. \sXDEF\s_GetCPUType\s; ID the CPU
  128. \sXDEF\s_GetFPUType\s; ID the FPU
  129. \sXDEF\s_GetMMUType\s; ID the MMU
  130. ;======================================================================
  131. ;\sThis function returns the type of the CPU in the system as a
  132. ;\slongword: 68000, 68010, 68020, or 68030.  The testing must be done
  133. ;\sin reverse order, in that any higher CPU also has the bits set for
  134. ;\sa lower CPU.  Also, since 1.3 doesn't recognize the 68030, if I
  135. ;\sfind the 68020 bit set, I always check for the presence of a 
  136. ;\s68030.
  137. ;\sThis routine should be the first test routine called under 1.2
  138. ;\sand 1.3.
  139. ;\sULONG GetCPUType(void);
  140. ;======================================================================
  141. _GetCPUType:
  142. \smovem.l\sa4/a5,-(sp)\s\s\s; Save this register
  143. \smove.l\s4,a6\s\s\s\s\s; Get ExecBase
  144. \sbtst.b\s#AFB_68030,ATNFLGS(a6)\s; Does the OS think an '030 is here?
  145. \sbeq\s0$
  146. \smove.l\s#68030,d0\s\s\s\s; Sure does...
  147. \smovem.l\s(sp)+,a4/a5
  148. \srts
  149. \sbtst.b\s#AFB_68020,ATNFLGS(a6)\s; Maybe a 68020?
  150. \sbne\s2$
  151. \sbtst.b\s#AFB_68010,ATNFLGS(a6)\s; Maybe a 68010?
  152. \sbne\s1$
  153. \smove.l\s#68000,d0\s\s\s\s; Just a humble '000
  154. \smovem.l\s(sp)+,a4/a5
  155. \srts
  156. \smove.l\s#68010,d0\s\s\s\s; Yup, we're an '010
  157. \smovem.l\s(sp)+,a4/a5
  158. \srts
  159. \smove.l\s#68020,d0\s\s\s\s; Assume we're an '020
  160. \slea\s3$,a5\s\s\s\s\s\s; Get the start of the supervisor code
  161. \sCALLSYS\sSupervisor
  162. \smovem.l\s(sp)+,a4/a5
  163. \srts
  164. \smovec\scacr,d1\s\s\s\s\s; Get the cache register
  165. \smove.l\sd1,a4\s\s\s\s\s; Save it for a minute
  166. \sbset.l\s#CIB_BURST,d1\s\s\s; Set the inst burst bit
  167. \sbclr.l\s#CIB_ENABLE,d1\s\s\s; Clear the inst cache bit
  168. \smovec\sd1,cacr\s\s\s\s\s; Try to set the CACR
  169. \smovec\scacr,d1
  170. \sbtst.l\s#CIB_BURST,d1\s\s\s; Do we have a set burst bit?
  171. \sbeq\s4$
  172. \smove.l\s#68030,d0\s\s\s\s; It's a 68030
  173. \sbset.b\s#AFB_68030,ATNFLGS(a6)
  174. \smove.l\sa4,d1\s\s\s\s\s; Restore the original CACR
  175. \smovec\sd1,cacr
  176. \srte
  177. ;======================================================================
  178. ;\sThis function returns 0L if the system contains no MMU, 
  179. ;\s68851L if the system does contain an 68851, or 68030L if the
  180. ;\ssystem contains a 68030 (built-in MMU).
  181. ;\sThis code runs just fine on boards from Ronin and 
  182. ;\sCommodore, as well as all 68030 boards it's been tested on.
  183. ;\sULONG GetMMUType(void)
  184. ;======================================================================
  185. _GetMMUType:
  186. \smove.l\s4,a6\s\s\s\s\s; Get ExecBase
  187. \smovem.l\sa3/a4/a5,-(sp)\s\s\s; Save this stuff
  188. \smove.l\s#0,a1\s
  189. \sCALLSYS\sFindTask\s\s\s\s; Call FindTask(0L)
  190. \smove.l\sd0,a3
  191. \smove.l\sTC_TRAPCODE(a3),a4\s\s; Change the exception vector
  192. \smove.l\s#2$,TC_TRAPCODE(a3)
  193. \smove.l\s#-1,d0\s\s\s\s; Try to detect undecode FPU
  194. \ssubq.l\s#4,sp\s\s\s\s\s; Let's try an MMU instruction
  195. \sdc.w\s$f017\s\s\s\s\s\s; like PMOVE tc,(sp)
  196. \sdc.w\s$4200
  197. \scmpi\s#0,d0\s\s\s\s\s\s; Any MMU here?
  198. \sbeq\s1$
  199. \scmpi\s#-1,d0\s\s\s\s\s; Hardware "features"?
  200. \sbeq\s1$
  201. \sbtst.b\s#AFB_68030,ATNFLGS(a6)\s; Does the OS think an '030 is here?
  202. \sbeq\s1$
  203. \smove.l\s#68030,d0
  204. \saddq.l\s#4,sp\s\s\s\s\s; Return that local
  205. \smove.l\sa4,TC_TRAPCODE(a3)\s\s; Reset exception stuff
  206. \smovem.l\s(sp)+,a3/a4/a5\s\s\s; and return the registers
  207. \srts
  208. \s; This is the exception code.  No matter what machine we're on,
  209. \s; we get an exception.  If the MMU's in place, we should get a
  210. \s; privilige violation; if not, an F-Line emulation exception.
  211. \smove.l\s(sp)+,d0\s\s\s\s; Get Amiga supplied exception #
  212. \scmpi\s#11,d0\s\s\s\s\s; Is it an F-Line?
  213. \sbeq\s3$\s\s\s\s\s\s; If so, go to the fail routine
  214. \smove.l\s#68851,d0\s\s\s\s; We have MMU
  215. \saddq.l\s#4,2(sp)\s\s\s\s; Skip the MMU instruction
  216. \srte
  217. \smoveq.l\s#0,d0\s\s\s\s\s; It dinna woik,
  218. \saddq.l\s#4,2(sp)\s\s\s\s; Skip the MMU instruction
  219. \srte
  220. ;\sThis function returns the type of the FPU in the system as a
  221. ;\slongword: 0 (no FPU), 68881, or 68882.
  222. ;\sULONG GetFPUType(void);
  223. _GetFPUType:
  224. \smove.l\sa5,-(sp)\s\s\s\s; Save this register
  225. \smove.l\s4,a6\s\s\s\s\s; Get ExecBase
  226. \sbtst.b\s#AFB_68881,ATNFLGS(a6)\s; Does the OS think an FPU is here?
  227. \sbne\s1$\s
  228. \smoveq.l\s#0,d0\s\s\s\s\s; No FPU here
  229. \smove.l\s(sp)+,a5\s\s\s\s; Give back the register
  230. \srts
  231. \slea\s2$,a5\s\s\s\s\s\s; Get the start of the supervisor code
  232. \sCALLSYS\sSupervisor
  233. \smove.l\s(sp)+,a5\s\s\s\s; Give back registers
  234. \srts
  235. \smove.l\s#68881,d0\s\s\s\s; Assume we're a 68881
  236. \sfsave\s-(sp)\s\s\s\s\s\s; Test and check
  237. \smoveq.l\s#0,d1
  238. \smove.b\s1(sp),d1\s\s\s\s; Size of this frame
  239. \scmpi\s#$18,d1
  240. \sbeq 3$
  241. \smove.l\s#68882,d0\s\s\s\s; It's a 68882
  242. \sfrestore (sp)+\s\s\s\s\s; Restore the stack
  243. \srte
  244. \send
  245. \B\I\O\ff<Bookman>\fs<14>A\.
  246. Black
  247. Black
  248. "PTXT
  249. b\n\B\ff<Helvetica>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Identifying the Amiga's CPU\.
  250. _PBOX
  251. ^PTXT
  252. W\n\B\ff<Helvetica>\fs<10>\jc\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Page III - 35\.
  253. N\n\B\ff<Helvetica>\fs<10>\jr\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Exec\.
  254. ;WPBOX
  255. `\n\B\I\O\ff<Helvetica>\fs<30>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Amiga Mail\ff<Times>
  256. ]JPBOX
  257. ^tPSGR
  258. Black
  259. Black
  260. c$PBOX
  261. d6PTXT
  262. P\n\I\ff<Times>\fs<12>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>May/June 1990\.
  263. Black
  264. Black
  265. wPBOX
  266. (PTXT
  267. K\n\B\ff<Helvetica>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Exec\.
  268. nPTXT
  269. W\n\B\ff<Helvetica>\fs<10>\jc\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Page III - 36\.
  270. DPTXT
  271. e\n\B\ff<Helvetica>\fs<10>\jr\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Identifying the Amiga's CPU\.
  272. `\n\B\I\O\ff<Helvetica>\fs<30>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Amiga Mail\ff<Times>
  273. 2PBOX
  274. Black
  275. Black
  276. Black
  277. Black
  278. b\n\B\ff<Helvetica>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Identifying the Amiga's CPU\.
  279. W\n\B\ff<Helvetica>\fs<10>\jc\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Page III - 37\.
  280. N\n\B\ff<Helvetica>\fs<10>\jr\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Exec\.
  281. V\n\B\I\O\ff<Helvetica>\fs<30>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Amiga Mail
  282. sPSGR
  283. Black
  284. Black
  285. FPPAG
  286. cPBOX
  287. Black
  288. Black
  289. IPTXT
  290. K\n\B\ff<Helvetica>\fs<10>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Exec\.
  291. IPBOX
  292. W\n\B\ff<Helvetica>\fs<10>\jc\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Page III - 38\.
  293. OPBOX
  294. e\n\B\ff<Helvetica>\fs<10>\jr\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Identifying the Amiga's CPU\.
  295. ~PTXT
  296. `\n\B\I\O\ff<Helvetica>\fs<30>\lr<120>\ls<0.000>\ps<100>\t<0>\c<Black>Amiga Mail\ff<Times>
  297. "PBOX
  298. MPSGR
  299. Black
  300. Black
  301.